package com.xsf.pay.common.exception;


import com.xsf.pay.common.domain.CodeMsg;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;

import java.io.Serial;
import java.util.HashMap;
import java.util.Map;

/**
 * @author 18961
 */
@Slf4j
@Getter
public class BusinessRunTimeException extends RuntimeException {

    @Serial
    private static final long serialVersionUID = 1L;
    private final int code;
    private final String msg;
    private Map<String, Object> data;

    public BusinessRunTimeException(int code, String reason) {
        super(reason);
        Map<String, Object> objectMap = new HashMap<>();
        objectMap.put("message", reason);
        this.code = code;
        this.data = objectMap;
        this.msg = reason;
    }
    public BusinessRunTimeException(CodeMsg codeMsg) {
        this.code = codeMsg.getCode();
        this.msg = codeMsg.getMsg();
    }
}
